<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>vui</title>
  <script type="text/javascript" src="../../src/core/vui.js"></script>
 </head>
 <body>
  <script type="text/javascript">
// ------测试------
// 新建一个Person类
VUI.Class('Person',{
	// 以下是类的方法列表:

	OPTS:{
		name:''
		,age:10
		,addr:'us'
	}
	// 构造方法
	,init:function(opts) {
		console.log('Person inited...' + opts.age)
		console.log(this.OPTS)
		this.gender = '男';
	}
	// 自定义方法
	,setName:function(name) {
		this.name = name;
	}
	,getName:function() {
		return (this.getClassName() + ' name:' + this.name)
	}
	,getGender:function() {
		return this.gender;
	}
});

var p = new VUI.Person({age:10});
//p.init();
p.setName('Jim')
console.log(p.getName());
console.log('Person gender:' + p.getGender());
console.log('Person className:' + p.getClassName());

// 新建一个接口
VUI.Interface('IPeople',['getName']);

// 新建一个类,继承Person类并且实现IPeople接口
VUI.Class('Man',{
	OPTS:{
		name:'man'
		,age:20
	}
	// 构造方法
	,init:function(opts) {
		this._super(opts);
		console.log('Man inited...' + opts.age)
		this.gender = '女';
		this.setName('Tom');
	}
	// 覆盖父类方法
	//@override
	,getGender:function() {
		var gender = this._super('getGender');// 调用父类方法
		return '{'+gender+'}';
	}
},VUI.Person).impl(VUI.IPeople);

var m = new VUI.Man({age:20});
console.log(m.getName());
console.log('Man gender:' + m.getGender());
console.log('Man className:' + m.getClassName());
console.log('m instanceof Person:' + (m instanceof VUI.Person));
console.log('m instanceof Man:' + (m instanceof VUI.Man));

/*
输出结果:
Person inited...10
Person name:Jim
Person gender:男
Person className:Person
Person inited...20
Man inited...20
Man name:Tom
Man gender:{女}
Man className:Man
m instanceof Person:true
m instanceof Man:true
*/
  </script>
 </body>
</html>
